package cn.cas.mango.controller;

import cn.cas.mango.dto.Message;
import cn.cas.mango.dto.param.QueryParam;
import cn.cas.mango.dto.param.TopicParam;
import cn.cas.mango.service.HotAxisByAdvService;
import java.io.IOException;

import cn.cas.mango.service.SearchService;
import cn.cas.mango.service.TopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/ReadingAssist/")
@ResponseBody
@CrossOrigin
public class AdvanceSearch {
  @Autowired
  private HotAxisByAdvService hotAxisByAdvService;
  @Autowired
  private SearchService searchService;
@Autowired
private TopicService topicService;
  @GetMapping
  public Message index() {
    return Message.builder().message("").build();
  }

  @RequestMapping(value = "advancedsearch/searchAdvanced", method = {RequestMethod.GET})
  public Message searchAdvanced(QueryParam queryParam) throws IOException {
    return searchService.searchAdvance(queryParam, "searchAdvanced");
  }

  @RequestMapping(value = "advancedsearch/searchAdvanced", method = {RequestMethod.POST})
  public Message searchAdvancedPost2(QueryParam queryParam) throws IOException {
    return searchService.searchAdvance(queryParam, "searchAdvanced");
  }


  @RequestMapping(value = "advancedsearch/getHotAxisByAdv", method = {RequestMethod.GET})
  public Message getHotAxisByAdv(QueryParam queryParam) throws IOException {
    return hotAxisByAdvService.getHotAxisByAdv(queryParam);
  }

  @RequestMapping(value = "advancedsearch/getHotAxisByAdv", method = {RequestMethod.POST})
  public Message getHotAxisByAdvPost(QueryParam queryParam) throws IOException {
    return hotAxisByAdvService.getHotAxisByAdv(queryParam);
  }


  @RequestMapping(value = "special/getNewsByTopic", method = {RequestMethod.GET})
  public Message getNewsByTopic(TopicParam topicParam) throws IOException {
    return topicService.run(topicParam);
  }

  @RequestMapping(value = "special/getNewsByTopic", method = {RequestMethod.POST})
  public Message getNewsByTopicPost(TopicParam topicParam) throws IOException {
    return topicService.run(topicParam);
  }

}
